package org.ccay.excel.importer.service;

import java.util.List;

import org.ccay.core.exception.ApplicationException;
import org.ccay.excel.importer.IExcelImportContext;

/**
 * Excel 读取出的数据的消费者
 * 
 * @author chaowangbang
 * @since 2011-12-3
 */
public interface IExcelDataConsumer {
	/**
	 * 任务开始
	 * 
	 * @param context
	 * @throws ApplicationException
	 */
	void begin(IExcelImportContext context) throws ApplicationException;

	/**
	 * 消费本批数据 
	 * @param context
	 * @param data
	 * @throws ApplicationException
	 */
	int useBatchData(List<?> data, IExcelImportContext context) throws ApplicationException;

	/**
	 * 导入数据的过程中发生错误
	 * 	
	 * @author chaowangbang
	 * @since Mar 21, 2012
	 * @throws ApplicationException
	 */
	void fail(IExcelImportContext context) throws ApplicationException;
	
	/**
	 * 任务结束，如果是导入到临时表，此处可以执行临时表到正式表的逻辑
	 * 错误写入ReadTaskContext.validationErrors
	 * 
	 * @param context
	 * @param result
	 * @throws ApplicationException
	 */
	void end(IExcelImportContext context) throws ApplicationException;
}
